package com.tedu.day01.oop;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;

public class SunJPanel extends JPanel implements Runnable{
	 int x=200;
	 int y=100;
	 Thread t;
	 public SunJPanel(){
		setBackground(Color.BLACK);
		t=new Thread(this);
		t.start();
	 }
    public void paint(Graphics g){
   	 super.paint(g);
   	g.setColor(Color.WHITE);
    g.fillOval(50,50,150,150);
   	 g.setColor(Color.BLACK);
   	 g.fillOval(x,50,150,150);
    }
	public void run() {
		while(true){
			x--; 
			if(x==80){
				x=200;
			}
			repaint();
			try {
				Thread.sleep(10);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}

}
}